home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
cppmatrx.zip
/
MATPARSE.BAK
< prev
next >
Wrap
Text File
|
1991-02-02
|
1KB
|
61 lines
#include <math.h>
#include <iostream.h>
#include "matrix.h"
#include "matparse.h"
static char current_token;
matrix expression (void)
{
matrix left = term ();
while (1) {
switch (current_token) {
case '+':
left = left + term (); break;
case '-':
left = left - term (); break;
case '!':
return left;
default:
matrix_error ("Invalid character in expression.");
}
}
}
matrix term (void)
{
matrix left = primary ();
switch (get_token ()) {
case '*':
left = left*primary (); break;
default:
return left;
}
}
matrix primary (void)
{
char ch;
matrix temp ("*",2);
cin >> ch;
cin >> temp;
cin >> ch;
return temp;
}
char get_token (void)
{
cin >> current_token;
return current_token;
}